<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">click</button>
    <script>
        const btn = document.getElementById('btn');

        function a() {
            console.log("点击了");
        }

        function debounce(fn, delay) {
            let timer = null;
            return function (...args) {
                clearTimeout(timer);
                timer = setTimeout(() => {
                    fn.call(this, ...args);
                }, delay)
            }
        }
        btn.addEventListener('click', debounce(a, 1000))
    </script>
</body>

</html>